import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AuthGuard } from './guard/auth/auth.guard';
import * as cookieParser from 'cookie-parser';
import * as session from 'express-session';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.use(cookieParser("I'm winner"));
  app.use(
    session({
      secret: 'keyword session',
      cookie: { maxAge: 90000, httpOnly: true },
      rolling: true,
    }),
  );

  // 全局配置守卫,注意这里的守卫需要实例化
  app.useGlobalGuards(new AuthGuard()); // 这样就实现了全局守卫

  await app.listen(3000);
}
bootstrap();
